<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <meta http-equiv="Content-Style-Type" content="text/css">
  <title></title>
  <meta name="Generator" content="Cocoa HTML Writer">
  <meta name="CocoaVersion" content="949.43">
  <style type="text/css">
    p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; text-align: center; font: 12.0px Helvetica; min-height: 14.0px}
    p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; text-align: center; font: 12.0px Helvetica}
    p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica}
    p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px}
  </style>
</head>
<body>
<p class="p1"><b></b><br></p>
<p class="p2"><b>How to write a plugin for Py4IJ</b></p>
<p class="p1"><b></b><br></p>
<p class="p3">Writing plugins is fairly simple.</p>
<p class="p4"><br></p>
<p class="p3"><b>Creating a plugin file</b></p>
<p class="p4"><br></p>
<p class="p3">By default a plugin filename should start with the '$' character and should be saved inside in the folder <i>plugins</i> inside Py4IJ. As an alternative you can create a sub-folder and put the plugin there. All the files starting with '$' will be detected by Py4IJ and will appear in the <b>Plugins menu</b>.</p>
<p class="p3">Pressing the <b>Plugins menu</b> item with the same name as the plugin will automatically run its code.</p>
<p class="p4"><b></b><br></p>
<p class="p3"><b>The plugin namespace</b></p>
<p class="p4"><b></b><br></p>
<p class="p3">All the variables available in the console are also available inside the plugin but not the other way around. A special dictionary called <i>myglobals </i>allows to creates variables that will appear in the console and <b>Object Tree</b>.<i> </i>For example: the line of code <i>myglobals['hello']=True </i>will generate the variable hello inside the console.</p>
<p class="p4"><br></p>
<p class="p3"><b>Calling plugins from inside plugins</b></p>
<p class="p4"><b></b><br></p>
<p class="p3">The special function <i>py4ij.runPlugin(plugpath)</i> allows you to run plugins directly from code. For example: <i>py4ij.runPlugin(os.path.join('Examples', '$Print_Image_Title.py'))</i> will run the example plugin.</p>
<p class="p4"><b></b><br></p>
<p class="p3"><b>Check the examples</b></p>
<p class="p4"><b></b><br></p>
<p class="p3">The directory Examples inside the Plugins folder has some examples. See them for more information.</p>
</body>
</html>
